<template>
  <div>
    <el-form ref="form" :rules="rules" :model="form" label-width="80px">
      <el-form-item label="公告名称" prop="title">
        <el-input v-model="form.title"></el-input>
      </el-form-item>
      <el-form-item label="公告内容" prop="message">
        <el-input :rows="10" type="textarea" v-model="form.message"></el-input>
      </el-form-item>

      <el-form-item>
        <el-button type="primary" @click="onSubmit">立即创建</el-button>
      </el-form-item>
    </el-form>
  </div>
</template>
<script>
export default {
  data() {
    return {
      form: {},
      rules: {
        title: [{ required: true, message: "必填项", trigger: "blur" }],
        message: { required: true, message: "必填项", trigger: "blur" },
      },
    };
  },
  methods: {
    onSubmit() {
      this.$refs.form.validate((valid) => {
        if (!valid) return;
        this.$http
          .post(
            "http://127.0.0.1:8080/minAdmin/send_notice",
            this.$qs.stringify(this.form)
          )
          .then((res) => {
            // console.log(this.form.message);
            this.$message.success("发布成功");
            this.form = {};
          });
      });
    },
  },
};
</script>
<style lang="less" scoped>
</style>
